import requests
import re

result = []
for page in range(1, 11):
    print(f"正在爬取第{page}页.............")
    url = f"https://quotes.toscrape.com/page/{page}/"
    res = requests.get(url)
    items = re.findall(r'<div class="quote"(.*?)</div>', res.text, re.S)
    for item in items:
        print(item)
        content = re.search(r'<span class="text" itemprop="text">“(.*?)”</span>', item, re.S)
        # print(content.group(1))

        author = re.search(r'itemprop="author">(.*?)</small>', item, re.S)
        # print(author.group(1))

        tags = re.findall(r'<a class="tag" href=".*?">(.*?)</a>', item, re.S)
        # print(tags)

        result.append({
            "content": content.group(1),
            "author": author.group(1),
            "tags": tags
        })
    print(result)
